<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
      let cites = [
        { py: 'beijing', name: '北京' },
        { py: 'alishan', name: '阿里山' },
        { py: 'beidaihe', name: '北戴河' },
        { py: 'shijiazhuang', name: '石家庄' },
      ];
      let obj = {};
      for (let i = 0; i < str.length; i++) {
        obj[str.charAt(i)] = [];
      }
      for (let i = 0; i < cites.length; i++) {
        for (let j = 0; j < Object.keys(obj).length - 1; j++) {
          if (cites[i].py[0] == Object.keys(obj)[j].toLowerCase()) {
            Object.values(obj)[j].push(cites[i]);
          }
        }
      }
      console.log(obj);
    </script>
  </body>
</html>
